package com.sx.manage.service.data.auth;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.sx.manage.biz.data.auth.IMDataAuthorityBiz;
import com.sx.model.manage.mybatis.form.data.auth.MDataAuthorityForm;
import com.sx.model.manage.mybatis.vo.consumer.login.MConsumerLoginVO;
import com.sx.model.manage.mybatis.vo.data.auth.MDataAuthorityVO;
import com.sx.model.manage.mybatis.vo.result.ResultBooleanVO;
import com.sx.model.manage.mybatis.vo.result.ResultListVO;

/**
 * 数据授权web端service
 * 
 * @author Administrator
 *
 */
@Service("dataAuthWebService")
public class MDataAuthWebService {
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	// 数据下载权限申请
	@Resource(name = "dataAuthorityBizImpl")
	private IMDataAuthorityBiz dataAuthorityBizImpl;

	/** 赋予权限**/
	public ResultBooleanVO grantAuth(MDataAuthorityForm form,MConsumerLoginVO loginConsumer){
		logger.info("赋予权限 form={}",form);
		form.setConsumer_id(loginConsumer.getConsumer_id());
		return dataAuthorityBizImpl.applyAuth(form);
	}
	/** 判断权限**/
	public ResultBooleanVO judgeAuth(MDataAuthorityForm form,MConsumerLoginVO loginConsumer) {
		logger.debug("判断权限 form={}",form);
		form.setConsumer_id(loginConsumer.getConsumer_id());
		return dataAuthorityBizImpl.judgeAuth(form);
	}
	/** 减少用户权限次数**/
	public ResultBooleanVO reduceAuth(MDataAuthorityForm form,MConsumerLoginVO loginConsumer) {
		logger.debug("减少用户权限次数form={}",form);
		form.setConsumer_id(loginConsumer.getConsumer_id());
		return dataAuthorityBizImpl.reduceAuth(form);
	}

	/** 申请通过 **/
	public ResultBooleanVO passAuth(Long id,MConsumerLoginVO loginVO) {
		logger.info("申请通过id={}", id);
		return dataAuthorityBizImpl.passAuth(id,loginVO);
	}

	/** 申请不通过 **/
	public ResultBooleanVO noPassAuth(Long id,MConsumerLoginVO loginVO) {
		logger.info("申请通过id={}", id);
		return dataAuthorityBizImpl.noPassAuth(id,loginVO);
	}
	/** 申请列表 **/
	public ResultListVO<MDataAuthorityVO> queryApplyPage(MDataAuthorityForm form,MConsumerLoginVO loginVO) {
		logger.info("授权信息分页form={}", form);
		form.setConsumer_id(loginVO.getConsumer_id());
		return dataAuthorityBizImpl.queryPage(form);
	}
	/** 申请列表 **/
	public ResultListVO<MDataAuthorityVO> queryPage(MDataAuthorityForm form) {
		logger.info("授权信息分页form={}", form);
		return dataAuthorityBizImpl.queryPage(form);
	}
}
